﻿// Study0621.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第六章 数组和指针 浅复制和深复制

#include <iostream>
#include "..\Study0619\ArrayOfPoints.h"
using namespace std;
int main()
{
    int count = 0;
    cout << "输入数组元素个数：" << endl;
    cin >> count;
    ArrayOfPoints pointsArray1(count);
    pointsArray1.getElement(0).move(5, 10);
    pointsArray1.getElement(1).move(15, 20);

    ArrayOfPoints pointsArray2(pointsArray1);
    cout << "复制pointsArray1得到pointsArray2:" << endl;
    cout << "Point_0 of array2: " << pointsArray2.getElement(0).getX() << ", "
        << pointsArray2.getElement(0).getY() << endl;
    cout << "Point_1 of array2: " << pointsArray2.getElement(1).getX() << ", "
        << pointsArray2.getElement(1).getY() << endl;
    cout << "修改pointsArray1的元素:" << endl;
    pointsArray1.getElement(0).move(25, 30);
    pointsArray1.getElement(1).move(35, 40);
    cout << "Point_0 of array2: " << pointsArray2.getElement(0).getX() << ", "
        << pointsArray2.getElement(0).getY() << endl;
    cout << "Point_1 of array2: " << pointsArray2.getElement(1).getX() << ", "
        << pointsArray2.getElement(1).getY() << endl;
    return 0;
}//如果不进行深复制，此处会运行错误，因为出现了指针悬挂的现象

